package WaiBao;

import java.util.Arrays;

public class YuanRuiRui {
    public static void main(String[] args) {
        String[] name = {"陈奕迅(班长)", "张信哲(副班长)", "小李(学习委员)", "陈宫(组织委员)", "称之为(宣传委员)", "曾志伟", "范彬彬", "范冰冰", "范兵兵", "洪金宝", "冯小刚", "杨幂",
                "杨紫", "赵露思", "林允", "刘少奇", "郭晨器", "李晨露", "李浩", "王城", "王自力", "王自立", "李天栋", "何亚东", "李高层", "利剑", "李剑", "李浩存",
                "吴奇隆", "袁蕊蕊(学生)"};//考生本人:袁蕊蕊(学生)
        int[] age = {21, 22, 21, 18, 21, 22, 21, 21, 19, 20, 19, 18, 21, 21, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 21, 18, 20, 20, 18, 19};//考生年龄19


        double[] yuyan1 = {64, 82, 85, 64, 88, 89, 71, 59, 60, 74, 90, 87, 84, 77, 65, 68, 65, 94, 96, 88, 95, 91, 95, 85, 75, 74, 74, 82, 84, 93};
        double[] yuyan2 = {82, 76, 77, 87, 75, 67, 91, 79, 82, 90, 74, 74, 86, 75, 75, 75, 86, 79, 66, 68, 82, 71, 85, 85, 75, 84, 84, 88, 87, 94};
        double[] yuyan3 = {77, 89, 89, 95, 90, 79, 69, 84, 80, 64, 83, 87, 85, 84, 65, 78, 89, 79, 96, 63, 92, 81, 95, 85, 76, 81, 77, 71, 74, 95};


        double gedan1;//代表每个学生的总分
        double gedan2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            gedan1 = yuyan1[i] + yuyan2[i] +yuyan3[i];
//            gedan2 = (gedan1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +gedan1);
//            System.out.println(name[i] + "的平均分为:" +gedan2);
//        }


        double tingshu1 = 0,tingshu2 = 0;
        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            tingshu1 = yuyan1[i] + yuyan2[i] + yuyan3[i];
//            tingshu2 = (tingshu1 * 1.0) / 3;
//            Array[i] = tingshu2;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double temp = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }


        double red1 = 0,red2 = 0,red3 = 0;//计算每门课的平均分
        double fun1 = 0, fun2 = 0,fun3 = 0;//计算每门课标准差
        double ciwo1 = 0, ciwo2 = 0, ciwo3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < yuyan1.length; i++) {
            sum2+=yuyan1[i];
        }
        red1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+red1);
        double Sum = 0;
        for (int i = 0; i <yuyan2.length; i++) {
            Sum+=yuyan2[i];
        }
        red2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+red2);
        double sum = 0;
        for (int i = 0; i <yuyan3.length; i++) {
            sum+=yuyan3[i];
        }
        red3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+red3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <yuyan1.length; i++) {
            c1+= (yuyan1[i] - red1)*(yuyan1[i] - red1);
        }
        fun1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+fun1);

        for (int i = 0; i < yuyan2.length; i++) {
            c2+= (yuyan2[i] - red2)*(yuyan2[i] - red2);
        }
        fun2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+fun2);

        for (int i = 0; i < yuyan3.length; i++) {
            c3+= (yuyan3[i] -red3)*(yuyan3[i] -red3);
        }
        fun3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+fun3);
////////
        Arrays.sort(yuyan1);
        Arrays.sort(yuyan2);
        Arrays.sort(yuyan3);
        ciwo1 =( yuyan1[15]+yuyan1[14])*1.0/2;
        ciwo2 =( yuyan2[15]+yuyan2[14])*1.0/2;
        ciwo3 =( yuyan3[15]+yuyan3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+ciwo1);
        System.out.println("线性代数的中位数为:"+ciwo2);
        System.out.println("有机化学学的中位数为:"+ciwo3);




    }
}
